﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Web.Mvc;
using projectManagementWeb.Validations;
using System.Web.Security;

namespace projectManagementWeb.Models
{
    /// <summary>
    /// This class encapsulates the model to represent all the information 
    /// about an existing task of the project.
    /// </summary>
    public class TaskDescriptionModel
    {
        projectmanagementDBDataContext _dbContext = null;
        
        public TaskDescriptionModel()
        {
            _dbContext = new projectmanagementDBDataContext();
        }

        public int TaskID { get; set; }
        public string TaskName { get; set; }
        public string TaskDescription { get; set; }
        public int ModuleID { get; set; }
        public string ModuleName { get; set; }
        public int ProjectID { get; set; }
        public string ProjectName { get; set; }
        [Required(ErrorMessage="El valor planeado es requerido")]
        [RegularExpression("[0-9]{1,}", ErrorMessage = "El campo Valor planeado debe ser número entero ")]
        public int PlannedEstimate { get; set; }
        [RegularExpression("[0-9]{1,}", ErrorMessage = "El campo Esfuerzo Invertido debe ser número entero ")]
        public int CurrentEffortDone { get; set; }
        [RegularExpression("[0-9]{1,}", ErrorMessage = "El campo Esfuerzo Faltante debe ser número entero ")]
        public int CurrentEffortPending { get; set; }
        public int CurrentStatus { get; set; }
        public string CurrentStatusName { get; set; }
        [Required(ErrorMessage = "El valor de fecha de inicio es requerido")]
        public DateTime StartDate { get; set; }
        [Required(ErrorMessage = "El valor de fecha de finalizacion es requerido")]
        public DateTime EndDate { get; set; }
        public DateTime RealEndDate { get; set; }

        public int userID { get; set; }

        public IEnumerable<SelectListItem> ModuleList
        {
            get
            {
                IEnumerable<SelectListItem> ModuleID = _dbContext.spGetProjectModules(userID)
                    .Select(i => new SelectListItem
                    {
                        Value = i.ID.ToString(),
                        Text = i.name.ToString()
                    }).ToList();
                return ModuleID;
            }

        }
    }
}